
class P352_39643 {

	static String readLn() {
		String newLine = System.getProperty("line.separator");
		StringBuffer buffer = new StringBuffer();
		int car = -1;
		try {
			car = System.in.read();
			while ((car > 0) && (car != newLine.charAt(0))) {
				buffer.append((char) car);
				car = System.in.read();
			}
			if (car == newLine.charAt(0))
				System.in.skip(newLine.length() - 1);
		} catch (java.io.IOException e) {
			return (null);
		}
		if ((car < 0) && (buffer.length() == 0))
			return (null);
		return (buffer.toString()).trim();
	}

	
	public static void main(String[] args) {
		String line = readLn();

		int k = 1;
		
		while (line != null) {
			System.out.print("Image number " + k + " contains ");
			process(Integer.parseInt(line));
			line = readLn();
			k++;
		}
	}
	
	private static void process(int n) {
		
		char[][] table = new char[n][n];
		
		for (int k = 0; k < n; k++) {
			String line = readLn();
			
			for (int j = 0; j < n; j++) {
				table[k][j] = line.charAt(j);
			}
			
		}
		
		int count = 0;
		
		for (int k = 0; k < n; k++) {
			for (int j = 0; j < n; j++) {
				
				if (table[k][j] == '1') {
					count++;
					process(table, n, n, k, j);
				}
				
			}
		}
		
		System.out.println(count + " war eagles.");
	}
	
	private static int process(char[][] land, int iLength, int jLength, int i, int j) {
		
		if (j >= 0 && j < jLength && i >= 0 && i < iLength) {
			
			if (land[i][j] != '1') return 0;
			
			land[i][j] = 'M';
			
			return 1 + process(land, iLength, jLength, i, j + 1) +
					process(land, iLength, jLength, i, j - 1) +
					process(land, iLength, jLength, i + 1, j + 1) +
					process(land, iLength, jLength, i + 1, j ) +
					process(land, iLength, jLength, i + 1, j - 1) +
					process(land, iLength, jLength, i - 1, j + 1 ) +
					process(land, iLength, jLength, i - 1, j ) +
					process(land, iLength, jLength, i - 1, j - 1 );
		}
		
		return 0;
		
	}

	
}
